package com.shopping.www.mapper;

import com.shopping.www.model.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper {
    //查询在货架上的商品的id
    @Select("select id from busniess_msg where shelveNum>0")
    int[] selectIds();
    //查询在货架上的商品
    List<Brand> selectAllBrand(@Param("ids") int[] ids,@Param("brand") Brand brand);
    //查询某个商品上架数量
    @Select("select shelveNum from busniess_msg where id=#{id}")
    int selectBusinessNum(int id);
    //验证是修改还是添加购物车信息
    Integer checkCart(@Param("brand_id") int brand_id,@Param("user_id") int user_id);
    //把商品添加到购物车
    void addToCart(@Param("brand_id") int brand_id,@Param("user_id") int user_id,@Param("cartNum") int cartNum);
    //修改购物车信息
    void updateCart(@Param("id") Integer id,@Param("cartNum") int cartNum);
    //查询所有belong的商品id数组
    @Select("select id from brand where belong=#{belong}")
    int[] selectSortIds(String belong);
    //查询购物车商品的id
    @Select("select brand_id from user_msg where cartNum>0 and user_id=#{user_id} and deliveryStatus=0")
    int[] selectCartIds(int user_id);
    //查询购物车商品数量
    @Select("select cartNum from user_msg where user_id=#{user_id} and cartNum>0")
    int[] selectCartNums(int user_id);
    //查询购物车上商品的货架数量
    int[] selectCartBrandMaxNum(@Param("ids") int[] ids);
    //查询商品信息
    List<Brand> selectBrands(@Param("ids") int[] ids);
    //查询下单商品是否已被封禁
    int checkCartBrandStatus(int brand_id);
    //改变购物车商品数量
    void updateCartNum1(@Param("brand_id") int brand_id,@Param("user_id") int user_id,@Param("num") int num);
    //删除购物车记录
    void deleteCartByIds(@Param("ids") int[] ids,@Param("user_id") int user_id);
    //把商品添加到订单
    void addToOrder(@Param("brand_id") int brand_id,@Param("user_id") int user_id,@Param("orderNum") int orderNum);
    //把商品添加到订单然后商家货架减
    void minxShelveNum(@Param("brand_id") int brand_id,@Param("shelveNum")int shelveNum,@Param("orderNum")int orderNum);
    //根据flag判断订单是从哪里下的，flag==1执行updateCartNum修改user_msg表
    void updateCartNum(@Param("brand_id")int brand_id ,@Param("orderNum") int orderNum);
    //查询订单商品brand_id
    @Select("select brand_id from user_msg where user_id=#{user_id} and orderNum>0")
    int[] selectOrderIds(int user_id);
    //查询订单商品数量
    @Select("select orderNum from user_msg where user_id=#{user_id} and orderNum>0")
    int[] selectOrderNums(int user_id);
    //查询订单商品id
    @Select("select id from user_msg where user_id=#{user_id} and orderNum>0")
    int[] selectDeleteOrder(int user_id);
    //删除订单记录
    void deleteOrder(int id);
    //用户点击配送时把deliveryStatus变成1
    void chooseDelivery1(@Param("user_id") int user_id,@Param("brand_id") int brand_id);
    //用户点击配送时把货架上货物减
    void chooseDelivery2(@Param("brand_id") int brand_id,@Param("maxNum")int maxNum,@Param("num") int num);
    //查询指定用户的delivery下的id
    @Select("select brand_id from user_msg where deliveryStatus>0 and cartNum>0 and user_id=#{user_id}")
    int[] selectDeliveryIds(int user_id);
    //查询指定用户的deliveryStatus
    @Select("select deliveryStatus from user_msg where deliveryStatus>0 and user_id=#{user_id}")
    int[] selectDeliveryStatus(int user_id);
    //结束配送
    void finishDelivery(@Param("user_id")int user_id,@Param("brand_id") int brand_id);
    //修改密码
    void updatePass(@Param("id") int id,@Param("password") String password);
}
